#include<iostream>
#include<cstdio>
using namespace std;
int a[9001];
int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	int n,q;
	cin>>n>>q;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=q;i++)
	{
		int s,x,v;
		cin>>s>>x;
		if(s==1) 
		{
			cin>>v;
			a[x]=v;
		}
		if(s==2)
		{
			int f[9001];
			for(int i=1;i<=n;i++){
				f[i]=a[i];
			} 
			int cnt=x;
			for (int b = 1; b <= n; b++)
				for (int j = b; j>=2; j--)
					if ( f[j] < f[j-1] )
					{
						if(j==cnt&&f[j]==a[x]) cnt--;
						if(j-1==cnt&&f[j-1]==a[x]) cnt++;
						int t = f[j-1];
						f[j-1] = f[j];
						f[j] = t;
					}
			cout<<cnt<<endl;
		}
	}
	return 0;
}
